********************************************************************************
*
*	Understanding the Impact of US Military Service on Support for Insurrection
*   Journal of Conflict Resolution
*   Replication
*
*   Robert A. Pape
*	Keven G. Ruby   
*	Kyle D. Larson
*   Kentaro Nakamura
*
*	Create figures in the article
*   
*   v2024-05-29
*
********************************************************************************

// Stata version = StataNow 18.5
version 18.5

/*
// These packages are needed for this do-file to run properly 
ssc install catplot, replace 
net install sensemakr, replace force from("https://raw.githubusercontent.com/resonance1/sensemakr-stata/master/")
ssc install coefplot, replace 
ssc install schemepack, replace
ssc install blindschemes, replace
*/

// Scheme used for figures
set scheme white_tableau

* Load data
use vetstudy_jcr_use.dta, clear

									  

********************************************************************************
*
* Figure 1. 
* Comparing Veterans and Non-Veterans on the Insurrectionist Index 
*
********************************************************************************

// Round and Simplify Index for Presentation
gen roundedindex = round(insurrection_index,1)

gen simplifiedindex = .
	replace simplifiedindex = 1 if roundedindex == 1 | roundedindex == 2
	replace simplifiedindex = 2 if roundedindex == 3
	replace simplifiedindex = 3 if roundedindex == 4 | roundedindex == 5

label define insl 	///
	1 "Low (1-2)" 	///
	2 "Medium (3)" 	///
	3 "High (4-5)"
	
label values simplifiedindex insl

catplot veteran, over(simplifiedindex) 						///
	asyvar bar(1, color(blue*.7)) bar(2, color(green*.7)) 	///
	ytitle("Percent of Sample") 							///
	b1title("Insurrectionist Sentiments Index") 			///
	bargap(2) scheme(white_tableau) percent(veteran) 		///
	vertical blabel(bar, format(%4.0f))
	
graph export fig_1.png, width (3000) replace 		// Figure 1


********************************************************************************
*
* Figure 2.
* Effect Estimates for Veteran at Varying Degrees of Hypothetical Confounding
*
********************************************************************************

/*
Method using:

Cinelli, Carlos, and Chad Hazlett. "Making sense of sensitivity: Extending 
omitted variable bias." Journal of the Royal Statistical Society: Series B 
(Statistical Methodology) 82.1 (2020): 39-67.
*/
local benchmark "b_republican b_childlaw i.age4 b_christian"	
local controls "b_republican b_childlaw b_white i.age4 b_male b_christian b_religious"	

sensemakr 	insurrection_index 			/// DV
			veteran 					/// Primary IV
			`controls' 					///
			, treat(veteran)  					///
			benchmark(`benchmark') 				///
			contourplot kd(4) clim(0 0.4)

graph play fix_sensemakr.grec // drop legend, drop cline labels that get in the way, move 0.00 label
graph display, xsize(1.5) ysize(1.5) scheme(plotplain)	  

// Output
graph export fig_2.png, replace width(3000)

drop if missing(caseid) // sensemakr generates additional observations that 
						// must now be dropped 

********************************************************************************
*
* Figure 3. 
* Diagram of Possible Mechanisms
* Generated using Powerpoint, no data involved  
*
********************************************************************************


********************************************************************************
*
* Figure 4.
* ACDE of Veteran by Mediator
*
********************************************************************************

/* Citation and Variable Definition
Code adapted from:

Acharya, Avidit, Matthew Blackwell, and Maya Sen. 2016. "Explaining Causal Findings 
Without Bias: Detecting and Assessing Direct Effects." American Political Science 
Review 110 (3): 512–29. https://doi.org/10/f9cr9k.

// variables
// y  = outcome
// a  = treatement
// m1 = mediator 1
// x  = pre-treatment confounders
// z  = post-treatment and intermediate confounders
// m2 = mediator 2

*/


* Define Variables Used in the Mediation Analysis, by Category *****************
local y  "insurrection_index" 			// Dependent Variable 
local a  "veteran"						// Treatment 
local z  "b_econconcern b_hardship"		// Post-Treatment Confounders 
local x  = "b_republican b_childlaw b_white i.age4 b_male b_christian b_religious"	// Pre-Treatment Confounders 

// Mediators (at most 2 for current code)
local m1 "b_conspiracy"
local m2 "b_polarization"


capture gen ytilde=.

// Both Mediators 
capture program drop deboot1
program define deboot1, rclass
  #delimit ;
  version 17.0;
  args y a m1 x z m2;
  regress `y' `m1' `m2' `x' `z';
  replace ytilde = `y' - _b[`m1']*`m1' - _b[`m2']*`m2';
  reg ytilde `a' `x';
  return scalar deffect = _b[`a'];
  #delimit cr
end

// Mediator 1
capture program drop deboot2
program define deboot2, rclass
  #delimit ;
  version 17.0;
  args y a m1 x z m2;
  regress `y' `m1'  `x' `z';
  replace ytilde = `y' - _b[`m1']*`m1';
  reg ytilde `a' `x';
  return scalar deffect = _b[`a'];
  #delimit cr
end

// Mediator 2
capture program drop deboot3
program define deboot3, rclass
  #delimit ;
  version 17.0;
  args y a m1 x z m2;
  regress `y' `m2'  `x' `z';
  replace ytilde = `y' - _b[`m2']*`m2';
  reg ytilde `a' `x';
  return scalar deffect = _b[`a'];
  #delimit cr
end


capture frame drop acdetab 						// drop if frame exists
frame create acdetab str20(l) bacde lb95 ub95  	// create frame

regress `y' `a' `x'	// Baseline Regression, including pretreatment confounders

frame post acdetab  ///
		("ATE of veteran") ///
		(_b[`a'])        ///
		(r(table)[5,1])  ///
		(r(table)[6,1])

forvalues i = 1/3 {
			
bootstrap deffect=r(deffect), reps(200) seed(12345): deboot`i' `y' `a' `m1' "`x'" "`z'" `m2'

local medlab = cond(`i'==1, "both", ///
			   cond(`i'==2, "conspiracy", "polarization"))

frame post acdetab      ///
	   ("`medlab'")        ///
	   (r(table)[1,1])  ///
	   (r(table)[5,1]) ///
	   (r(table)[6,1])
}	
	
frame acdetab {
		gsort bacde
		capture gen seq=_n
		replace seq = _n
		list seq l bacde lb95 ub95
		
		replace l = "ACDE of veteran | M = conspiracy" if l == "conspiracy"
		replace l = "ACDE of veteran | M = support for Trump" if l=="polarization"
		replace l = "ACDE of veteran | M = both" if l == "both"
		
		twoway  rcap lb95 ub95 seq, horizontal || ///
		       scatter  seq bacde, msymbol(O) mcolor(black) mlabel(l) mlabpos(12) mlabgap(1) mlabsize(medium) ///
			   xline(0, lcolor(red)) ///
			   xlabel(-.05(.05).35, labsize(medium)) scheme(plotplain) yscale(range(.5 4.5)) xtitle(Estimated Effect of Veterancy) ///
			   ylabel(,nolabels notick) ytitle("Mediator Specifications") legend(off) ///
			   xsize(5) ysize(3) 
		graph export fig_4.png, width(3000) replace
}

frame  drop acdetab


********************************************************************************
*
* 	Figure 5. Mediation Sensitivity Analysis 
*
********************************************************************************

/* Citation and Variable Definition
Code adapted from:

Acharya, Avidit, Matthew Blackwell, and Maya Sen. 2016. "Explaining Causal Findings 
Without Bias: Detecting and Assessing Direct Effects." American Political Science 
Review 110 (3): 512–29. https://doi.org/10/f9cr9k.

// variables
// y  = outcome
// a  = treatement
// m1 = mediator 1
// x  = pre-treatment confounders
// z  = post-treatment and intermediate confounders
// m2 = mediator 2

*/

capture gen ytilde=.
capture gen yresid=.
capture gen mresid=.
capture drop ypred
capture drop mpred
/*
capture gen iv_liketrump = cond(favortrump>3,1,0)
capture gen iv_polarizedr = cond(affpol>2,1,0)
*/

local y  "insurrection_index" 
local a  "veteran"
local m  "b_conspiracy b_polarization"
local x  "b_republican b_childlaw b_white i.age4 b_male b_christian b_religious"
local z  "b_econconcern b_hardship"

foreach mediator in `m' {

capture frame drop acdesens
frame create acdesens rho acde lb95 ub95 

local vl : variable label `mediator'

* First Stage
	regress `y' `a' `mediator' `x'
	local bm = _b[`mediator']
	predict ypred
	replace yresid = `y' - ypred
	capture gen ytilde
	replace ytilde = `y' - _b[`mediator']*`mediator'
	regress ytilde `a' `x'
* Second stage
	logit `mediator' `a' `z'
	predict mpred
	replace mresid = `mediator' - mpred // demediated dv for mediation regression
	drop mpred ypred
	
    correlate yresid mresid // correlation between mediator resid and outcome resid
	local rho_tilde = r(rho)^2
	egen sdy = sd(yresid)
	egen sdm = sd(mresid)

* For each value of rho, caclulate the corr	
foreach r of numlist -0.9(.05)0.9 {
	gen rho = `r'
	gen rho_factor = rho*sqrt((1-`rho_tilde')/(1-rho^2))
	gen mfixed = `bm' - sdy * rho_factor/sdm
	replace ytilde = `y' - mfixed * `mediator'
	drop rho mfixed rho_factor
	* calculate acde for each rho
	bootstrap acde = _b[`a'], reps(200) seed(12345): regress ytilde `a' `x'
    * store results for rho acde lowerci upperci in data frame medsens
	frame post acdesens ///
	(`r') ///               
	(r(table)[1,1]) ///
	(r(table)[5,1]) ///
	(r(table)[6,1])
	
	}

drop sdy sdm 
	
frame acdesens {
	
twoway rarea lb95 ub95 rho, fcolor(black%25) lwidth(0) || ///
	   line acde rho, lcolor(black) lpattern(solid) ///
	   xline(0) yline(0, lcolor(red)) ///
	   xtitle("Correlation between mediator and outcome errors ({&rho})") ///
	   ytitle("Estimated ACDE") ///
	   legend(off) ///
	   ylab(-1(.5)1) ///
	   xlab(-1(.5)1) ///
	   aspect(1) scheme(plotplain) xsize(2) ysize(2) ///
	   title("`vl'", bmargin(2)) name(n`mediator', replace)
	   graph export n`mediator'.png, replace
      
}

frame  drop acdesens
}

graph combine nb_conspiracy nb_polarization, ycommon xcommon 
graph export fig_5.png, replace width(3000)

// erase individual subgraphs no longer needed
erase nb_conspiracy.png 
erase nb_polarization.png


********************************************************************************
*
* Figure 6.
* Military Service Interaction Plots
*
********************************************************************************
estimates clear 

local controls "b_republican b_childlaw b_white i.age4 b_male b_christian b_religious"	
local servicevars "b_combattrauma b_discharged b_servedgwot b_singletour b_combatdeployment"
local postservicevars "b_unappreciated b_notproud b_reintegration b_disillusioned b_ptsd"


// Change missing to 0 for nonvets (veteran==0) for service and postservice
// treating nonveterans as veterans who do not have the given factor
// for the comparative analyis
   
local servicevars "b_combattrauma b_discharged b_servedgwot b_singletour b_combatdeployment"
local postservicevars "b_unappreciated b_notproud b_reintegration b_disillusioned b_ptsd"

foreach var of varlist `servicevars' `postservicevars' {
	
	replace `var' = 0 if veteran == 0 	// Set all non-veterans to 0	
}


local counter = 1

foreach iv of varlist `servicevars' `postservicevars' {
	
	regress insurrection_index 									/// DV
			i.veteran#i.`iv' 									/// IV
			`controls' 											///
		, robust	
			
	margins i.veteran#i.`iv', atmeans post	// Margins	
	estimates store v1_`counter'			// Store the Estimates for Plot
	
local counter = `counter' + 1
}
		

 * Service Factors (top) *******************************************************

coefplot ///
	(v1_1, keep(1.veteran#1.b*) label("Vet With")  msymbol(d) mcolor(green) ciopts(lcolor(green))) 								///
	(v1_1, keep(1.veteran#0.b*) label("Vet Without") msymbol(s) mcolor(green) ciopts(lcolor(green)))  							///
	(v1_1, keep(0.veteran#0.b*) label("Non-Vet") msymbol(s) mcolor(blue) ciopts(lcolor(blue))), bylabel("Combat" "Trauma") || 	///
	(v1_2, keep(1.veteran#1.b*)) 												///
	(v1_2, keep(1.veteran#0.b*))  												///
	(v1_2, keep(0.veteran#0.b*)), bylabel("Involuntary" "Discharge") || 		///
	(v1_3, keep(1.veteran#1.b*)) 												///
	(v1_3, keep(1.veteran#0.b*))  												///
	(v1_3, keep(0.veteran#0.b*)), bylabel("Service During" "GWoT") 	|| 			///
	(v1_4, keep(1.veteran#1.b*)) 												///
	(v1_4, keep(1.veteran#0.b*))  												///
	(v1_4, keep(0.veteran#0.b*)), bylabel("4 Years or Less" "of Service") || 	///
	(v1_5, keep(1.veteran#1.b*)) 												///
	(v1_5, keep(1.veteran#0.b*))  												///
	(v1_5, keep(0.veteran#0.b*)), bylabel("Combat" "Deployed") 					///
	vertical ///
    msize(huge) mfcolor(white) ///
    mlabel(string(round(@b,0.001), "%9.2f")) /// turn the value into a string and trim the leading zero
    mlabposition(0) ///
    grid(within) ///
	byopts(compact row(1) legend(off)) ///
    drop(_cons) ///
	rename(												///
		1.veteran#1.b_combattrauma     	= "Vet With" 	///
		1.veteran#0.b_combattrauma     	= "Vet Without" ///
		0.veteran#0.b_combattrauma     	= "Non-Vet" 	///
		1.veteran#1.b_discharged 		= "Vet With" 	///
		1.veteran#0.b_discharged 		= "Vet Without" ///
		0.veteran#0.b_discharged 		= "Non-Vet" 	///
		1.veteran#1.b_servedgwot 		= "Vet With" 	///
		1.veteran#0.b_servedgwot 		= "Vet Without" ///
		0.veteran#0.b_servedgwot 		= "Non-Vet" 	///
		1.veteran#1.b_singletour 		= "Vet With" 	///
		1.veteran#0.b_singletour 		= "Vet Without" ///
		0.veteran#0.b_singletour 		= "Non-Vet" 	///
		1.veteran#1.b_combatdeployment 	= "Vet With" 	///
		1.veteran#0.b_combatdeployment 	= "Vet Without"	///
		0.veteran#0.b_combatdeployment	= "Non-Vet" 	///
		) 												///
	title("")  											///
	ytitle("Predicted Index Score") 					///
	xlabel("") 											///
	yline(1.591431, lcolor(blue)) 						/// put line at non-veteran mean value 
	ylab(1(0.5)2.5) 									///
	legend(off) 										///
	xsize(6.5) ysize(3) scheme(white_tableau) 			///
	name(int_1, replace)
	

* Post-Service Factors (bottom) ************************************************
	
coefplot ///
	(v1_6, keep(1.veteran#1.b*) label("Vet With")  msymbol(d) mcolor(green) ciopts(lcolor(green))) 										///
	(v1_6, keep(1.veteran#0.b*) label("Vet Without") msymbol(s) mcolor(green) ciopts(lcolor(green)))  									///
	(v1_6, keep(0.veteran#0.b*) label("Non-Vet") msymbol(s) mcolor(blue) ciopts(lcolor(blue))), bylabel("Service" "Unappreciated") || 	///
	(v1_7, keep(1.veteran#1.b*)) 												///
	(v1_7, keep(1.veteran#0.b*))  												///
	(v1_7, keep(0.veteran#0.b*)), bylabel("No Pride in" "Service") || 			///
	(v1_8, keep(1.veteran#1.b*)) 												///
	(v1_8, keep(1.veteran#0.b*))  												///
	(v1_8, keep(0.veteran#0.b*)), bylabel("Reintegration" "Trouble") || 		///
	(v1_9, keep(1.veteran#1.b*)) 												///
	(v1_9, keep(1.veteran#0.b*))  												///
	(v1_9, keep(0.veteran#0.b*)), bylabel("Disillusioned" "with Service") || 	///
	(v1_10, keep(1.veteran#1.b*)) 												///
	(v1_10, keep(1.veteran#0.b*)) 	 											///
	(v1_10, keep(0.veteran#0.b*)), bylabel("Service-Related" "PTSD") 			///
	vertical ///
    msize(huge) mfcolor(white) ///
    mlabel(string(round(@b,0.001), "%9.2f")) /// turn the value into a string and trim the leading zero
    mlabposition(0) ///
    grid(within) ///
	byopts(compact row(1) legend(off)) ///
    drop(_cons) ///
	rename(	///
		1.veteran#1.b_notproud     	= "Vet With" ///
		1.veteran#0.b_notproud     	= "Vet Without" ///
		0.veteran#0.b_notproud     	= "Non-Vet" ///
		1.veteran#1.b_reintegration = "Vet With" ///
		1.veteran#0.b_reintegration = "Vet Without" ///
		0.veteran#0.b_reintegration = "Non-Vet" ///
		1.veteran#1.b_disillusioned = "Vet With" ///
		1.veteran#0.b_disillusioned = "Vet Without" ///
		0.veteran#0.b_disillusioned = "Non-Vet" ///
		1.veteran#1.b_unappreciated = "Vet With" ///
		1.veteran#0.b_unappreciated = "Vet Without" ///
		0.veteran#0.b_unappreciated = "Non-Vet" ///
		1.veteran#1.b_ptsd          = "Vet With" ///
		1.veteran#0.b_ptsd          = "Vet Without" ///
		0.veteran#0.b_ptsd          = "Non-Vet") ///
	title("")  ///
	ytitle("Predicted Index Score") ///
	xlabel("") ///
	yline( 1.591431, lcolor(blue)) /// put line at non-veteran mean value 
	xsize(6.5) ysize(3) scheme(white_tableau) ///
	name(int_2, replace) 

// Output
graph combine int_1 int_2, rows(2) ycommon xcommon 
graph export fig_6.png, replace width(3000) 


********************************************************************************
*
* Table 1.
* Comparison of National and Sample Veteran Characteristics 
*
********************************************************************************
		
table () veteran, ///
	stat(mean i.age4 1.b_male  1.b_nocollege i.race4 i.msr2 i.b_officer) ///
	nformat(%9.2f)
	
/*
The veteran sample closely reflects the veteran population on the selected 
demographic and military factors. The comparison sample of non-veterans is also 
aligned on the key matching characteristics. While there are a small of number 
of differences between individual factors, the three populations are 
statistically indistinguishable across the demographic factors as a whole 
(χ2 (18) = 5.689, p=.997).
*/
// Chi2 Veteran Pop vs Veteran Sample vs Non-Veteran Sample
tabi 9 7 8 \ 29 25 31 \ 44 46 43 \ 18 22 18 \ 81 80 84 \ 66 66 71 \ 65 70 69 \ 13 14 17 \ 11 9 11 \ 9 6 3, chi2  // Pearson chi2(18) 5.689 Pr 0.997
		


********************************************************************************
*
* Table 2.
* Demographics of Veterans with and without High Insurrectionist Sentiments
*
********************************************************************************
preserve 
	drop if veteran==0

	tab age4, gen(age4_)
	tab race4, gen(race4_)
	tab region4, gen(region4_)
	tab msr2, gen(msr2_)
	tab msr4, gen(msr4_)
	tab b_officer, gen(rank_)

	collect clear

			local myresults "NoIns = r(mu_1) YesIns = r(mu_2)  Diff = (r(mu_2)-r(mu_1)) Pval = r(p)"
			table (command) (result), ///
			command(`myresults': ttest age4_1, by(b_insurrect))  			/// 1
			command(`myresults': ttest age4_2, by(b_insurrect))  			/// 2
			command(`myresults': ttest age4_3, by(b_insurrect))  			/// 3
			command(`myresults': ttest age4_4, by(b_insurrect))  			/// 4
			command(`myresults': ttest b_male, by(b_insurrect))  			/// 5
			command(`myresults': ttest b_nocollege, by(b_insurrect)) 	 	/// 6 
			command(`myresults': ttest race4_1, by(b_insurrect))  			/// 7
			command(`myresults': ttest race4_2, by(b_insurrect))  			/// 8
			command(`myresults': ttest race4_3, by(b_insurrect))  			/// 9
			command(`myresults': ttest race4_4, by(b_insurrect))  			/// 10
			command(`myresults': ttest msr2_1, by(b_insurrect))  			/// 11 
			command(`myresults': ttest msr2_2, by(b_insurrect))  			/// 12 
			command(`myresults': ttest msr2_3, by(b_insurrect))  			/// 13 
			command(`myresults': ttest msr2_4, by(b_insurrect))  			/// 14 
			command(`myresults': ttest msr2_5, by(b_insurrect))  			/// 15
			command(`myresults': ttest msr4_2, by(b_insurrect))  			/// 16
			command(`myresults': ttest rank_1, by(b_insurrect))  			/// 17
			command(`myresults': ttest rank_2, by(b_insurrect))  			/// 18
			command(`myresults': ttest region4_1, by(b_insurrect))  		/// 19
			command(`myresults': ttest region4_2, by(b_insurrect))  		/// 20
			command(`myresults': ttest region4_3, by(b_insurrect))  		/// 21
			command(`myresults': ttest region4_4, by(b_insurrect))  		/// 22
			nformat(%5.3f)

			collect label list command, all
			
			collect label levels command 	1 "Age4_1" ///
											2 "Age4_2" ///
											3 "Age4_3" ///
											4 "Age4_4" ///
											5 "Male" ///
											6 "No BA" ///
											7 "Race: White" ///
											8 "Race: Black" ///
											9 "Race: Hispanic" ///
											10 "Race: Other" ///
											11 "Army" ///
											12 "Navy" ///
											13 "Marines" ///
											14 "Air Force" ///
											15 "Coast Guard" ///
											16 "Special Forces" ///
											17 "Enlisted" ///
											18 "Office" ///
											19 "Region: NE" ///
											20 "Region: MW" ///
											21 "Region: S" ///
											22 "Region: W" ///
											, modify
	
			collect save "tabel2", replace
			 
	
	// Export Table to Word
	putdocx clear
	putdocx begin
	putdocx paragraph, style(Title)
	putdocx text ("Demographics of Veterans with and without High Insurrectionist Sentiments")

	collect clear
	collect use tabel2
	putdocx paragraph, style(Heading3)
	collect style putdocx, layout(autofitcontents)   
	putdocx collect
	putdocx save tab_2.docx, replace


restore



********************************************************************************
*
* Table 3.
* Effect of Veteran on Insurrectionist Sentiments Index
*
********************************************************************************

// Establish list of Pre-Treatment Controls for all subsequent regressions 		   #####
local controls "b_republican b_childlaw b_white i.age4 b_male b_christian b_religious"

regress 	insurrection_index 			/// DV
			veteran 					/// Primary IV
			`controls' 					///
	, robust

estimates store main

// Output
esttab main using tab_3.rtf, replace se(3) label r2  ///
    note("Note. Results from OLS.  Robust standard errors in parentheses.")
	

********************************************************************************
*
* Table 4.
* Service and Post-Service Experiences among Veterans with and without Insurrectionist Sentiments
*
********************************************************************************

preserve 
	drop if veteran==0

	tab age4, gen(age4_)
	tab race4, gen(race4_)
	tab region4, gen(region4_)
	tab msr2, gen(msr2_)
	tab msr4, gen(msr4_)
	tab b_officer, gen(rank_)

	collect clear

			local myresults "NoIns = r(mu_1) YesIns = r(mu_2)  Diff = (r(mu_2)-r(mu_1)) Pval = r(p)"
			table (command) (result), ///
			command(`myresults': ttest b_servedgwot, by(b_insurrect)) 		/// 1
			command(`myresults': ttest b_singletour, by(b_insurrect)) 		/// 2
			command(`myresults': ttest b_combatdeployment, by(b_insurrect))	/// 3
			command(`myresults': ttest b_discharged, by(b_insurrect)) 		/// 4
			command(`myresults': ttest b_combattrauma, by(b_insurrect)) 	/// 5
			command(`myresults': ttest b_reintegration, by(b_insurrect))	/// 6
			command(`myresults': ttest b_disillusioned, by(b_insurrect)) 	/// 7
			command(`myresults': ttest b_unappreciated, by(b_insurrect)) 	/// 8
			command(`myresults': ttest b_ptsd, by(b_insurrect)) 			/// 9
			command(`myresults': ttest b_proud, by(b_insurrect)) 			/// 10
			command(`myresults': ttest b_notproud, by(b_insurrect)) 		/// 11
			nformat(%5.3f)

			collect label list command, all
			
			collect label levels command 	1 "Service During GWoT" 		///
											2 "4 Years of Service or Less" 	///
											3 "Combat Deployed" 			///
											4 "Involuntary Discharge" 		///
											5 "Combat Trauma" 				///
											6 "Reintegration Trouble" 		///
											7 "Disillusioned with Service" 	///
											8 "Service Unappreciated" 		///
											9 "Service-Related PTSD" 		///
											10 "Proud in Service" 			/// Not included in table
											11 "No Pride in Service" 		///
											, modify
	
			collect save "tabel2", replace
				
	// Export Table to Word
	putdocx clear
	putdocx begin
	putdocx paragraph, style(Title)
	putdocx text ("Demographics of Veterans with and without High Insurrectionist Sentiments")

	collect clear
	collect use tabel2
	putdocx paragraph, style(Heading3)
	collect style putdocx, layout(autofitcontents)   
	putdocx collect

	putdocx save tab_4.docx, replace
	
restore
	


********************************************************************************
*
* IN-TEXT CALCULATIONS
*
********************************************************************************

 * Index Construction Alpha Scores *********************************************
alpha force force_personal, ///
	casewise // Insurruectionist Sentiments Index (DV)

alpha conspiracy_qanon conspiracy_jailpatriots conspiracy_demreplacement, ///
	casewise // Conspiracy Index (Mediator)
	
alpha combat mortalfear sawfriendkilled sawenemykilled sawcivskilled, ///
	casewise // Combat Trauma (For Interaction Analysis)

 * Descriptive Statistics ******************************************************
/* 
On the 5-point insurrection sentiments index, veterans have a mean value of 1.9, 
while demographically matched non-veterans have a mean value of 1.6, meaning 
veterans have on average 20% higher insurrectionist sentiments than 
non-veterans, statistically significant at the .001 level.
*/

table () veteran, ///
	stat(mean insurrection_index) ///
	nformat(%9.1f)
	
/* 
Indeed, our in our data, 23% of veterans believe in far-right conspiracies, 
compared to 15% of non-veterans.
*/
/*
In our data, 35% of veterans have high relative support for Trump, 
compared to 27% of non-veterans. 
*/
table () veteran, ///
	stat(mean b_conspiracy b_polarization) ///
	nformat(%9.2f)

 * T-Tests *********************************************************************
/*
Veterans under 65 are approximately 10% more likely to be Republican than 
demographically matched non-veterans (49% vs 38%, t(1661)=-4.473, p<0.001). 
*/
ttest b_republican, by(veteran)

/*
Republicans are also more likely to possess insurrectionist sentiments than 
non-Republicans (15% vs 5%, t(1661)=-6.98, p<0.001). 
*/
ttest b_insurrect, by(b_republican)


// Cleanup

erase tabel2.stjson	



